package com.example.scrawldemo.API;


import android.app.Activity;
import android.content.Context;
import android.util.Log;


import com.example.scrawldemo.base.BaseApplication;
import com.example.scrawldemo.util.JSONUtils;
import com.example.scrawldemo.util.MyOkGoHelper;
import com.example.scrawldemo.util.SpfUtils;

import java.util.HashMap;
import java.util.Map;


/**
 * Created by 他的猫 on 2017/5/10.
 */

public class API {


    public static String getBase() {
        String ip = (String) SpfUtils.get(BaseApplication.getInstance(), "ip", "39.104.207.210");
//        String url = "http://" + ip + ":8080/";
        String url = "http://" + ip + ":84/api/";
        Log.e("url", url);
        return url;
    }

    /**
     *  获得需要的参数
     *
     * @para
     */
    public static void GetValue(Activity context,   MyOkGoHelper.Objectcallback handler) {
        Map<String, Object> map = new HashMap<>();
        map.put("uid", "341");
        map.put("token", "wJUhxdXDAbIsI0eXuEVnwprAXegTnfk7GHHaIi0T0Fa0nnmAbInQxp81FmvL58mzYyI2KNf5njCohnoKlh3K1og2Yg9QxUVqpz9pHdNtL17iDknqPL9RweYL215bJLzH");
        String s = JSONUtils.mapToJson(map);
        Log.e("888", s);
        MyOkGoHelper.post(  context, "http://123.207.88.200:9000/singcampus/getUploadToken", map, handler);

    }
    /**
     * 递交收藏
     *
     * @param handler
     */
    public static void  PostData(Activity context, String url_media, String title, String filesize,

                                 MyOkGoHelper.Objectcallback handler) {
        Map<String, Object> map = new HashMap<>();
        map.put("mediatype", 0);
        map.put("url_media", url_media);

        map.put("title", title);
        map.put("filesize",  Integer.parseInt(filesize) );
        map.put("duration", 0);

        String s = JSONUtils.mapToJson(map);
        Log.e("888", s);

        MyOkGoHelper.post( context,"http://123.207.88.200:9000/singcampus/saveMediaToMyMaterials", map, handler);

    }







}
